package com.fr.privilege.user;

import com.fr.base.StringUtils;
import com.fr.privilege.authority.Authority;

public class UserDetails
  implements User
{
  private static final long serialVersionUID = 8273109812994175623L;
  private String password;
  private String username;
  private Authority[] authorities;

  public UserDetails(String paramString1, String paramString2, Authority[] paramArrayOfAuthority)
  {
    if ((StringUtils.isBlank(paramString1)) || (paramString2 == null))
      throw new IllegalArgumentException("Cannot pass null or empty values to constructor");
    this.username = paramString1;
    this.password = paramString2;
    setAuthorities(paramArrayOfAuthority);
  }

  public Authority[] getAuthorities()
  {
    return this.authorities;
  }

  public String getPassword()
  {
    return this.password;
  }

  public String getUsername()
  {
    return this.username;
  }

  protected void setAuthorities(Authority[] paramArrayOfAuthority)
  {
    this.authorities = paramArrayOfAuthority;
  }

  public String toString()
  {
    StringBuffer localStringBuffer = new StringBuffer();
    localStringBuffer.append(super.toString()).append(": ");
    localStringBuffer.append("Username: ").append(this.username).append("; ");
    localStringBuffer.append("Password: [PROTECTED]; ");
    if (getAuthorities() != null)
    {
      localStringBuffer.append("Granted Authorities: ");
      int i = 0;
      while (true)
      {
        if (i >= getAuthorities().length)
          break label111;
        if (i > 0)
          localStringBuffer.append(", ");
        localStringBuffer.append(getAuthorities()[i].toString());
        ++i;
      }
    }
    localStringBuffer.append("Not granted any authorities");
    label111: return localStringBuffer.toString();
  }
}